package com.sl.job;

import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuarzJobConfig {

	@Bean
	public JobDetail createMyJobDetail() {  
		return JobBuilder.newJob(TestJob.class).withIdentity("testJob").storeDurably().build();
	}
	@Bean
	public Trigger createMyJobTrigger() {
	    return TriggerBuilder.newTrigger().forJob(createMyJobDetail()).withIdentity("testJob").
	    withSchedule(CronScheduleBuilder.cronSchedule("0/2 * * * * ?").
	    withMisfireHandlingInstructionFireAndProceed()).build();
	}
}
